<script setup>
    import * as echarts from 'echarts';
    import { ref, onMounted } from 'vue';
    //获取图形图标的节点
    let line = ref();
    onMounted(() => {
        let mycharts = echarts.init(line.value);
        //设置配置项
        mycharts.setOption({
            //标题组件
            title: {
                text: ''
            },
            //x|y轴
            xAxis: {
                type: 'category',
                //两侧不留白
                boundaryGap: false,
                //分割线不要
                splitLine: {
                    show: false
                },
                data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                //轴线的设置
                axisLine: {
                    show: true
                },
                //刻度
                axisTick: {
                    show: true
                },
                axisLabel: {
                    fontSize: 16 // x轴刻度字体大小
                }
            },
            yAxis: {
                splitLine: {
                    show: false
                },
                //轴线的设置
                axisLine: {
                    show: true
                },
                //刻度
                axisTick: {
                    show: true
                },
                axisLabel: {
                    fontSize: 16 // y轴刻度字体大小
                }
            },
            grid: {
                left: 60,
                top: 10,
                right: 20,
                bottom: 30
            },
            //系列
            series: [
                {
                    type: 'line',
                    data: [120, 1240, 66, 2299, 321, 890, 1200],
                    //平滑曲线的设置
                    smooth: true,
                    //区域填充样式
                    areaStyle: {
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: 'red' // 0% 处的颜色
                            }, {
                                offset: 1, color: 'blue' // 100% 处的颜色
                            }],
                            global: false // 缺省为 false
                        }
                    }
                }
            ]
        })
    })
</script>

<template>
    <div class="box">
        <div class="top">
            <div>
                <p class="title">未来七天游客数量趋势图</p>
                <img
                    src="../../images/dataScreen-title.png"
                    alt=""
                >
            </div>
        </div>
        <div
            class="charts"
            ref='line'
        ></div>
    </div>
</template>
<style scoped>
    .box {
        background: url(../../images/dataScreen-main-lb.png) no-repeat;
        background-size: 100% 100%;
        margin: 0px 20px;
        margin-top: 10px;

    }

    .top {
        margin-left: 20px;
        height: 70px;
        display: flex;
        align-items: center;
    }

    .top .title {
        color: white;
        font-size: 20px;
    }

    .top img {
        margin-top: 10px;
    }

    .charts {
        height: calc(100% - 70px);
        padding: 20px;
    }
</style>